// ftp文件窗口可拖动
// 传入元素ID 即可实现元素拖动
function ftpDrag(id) {
    var odrag = document.getElementById(id);
    odrag.onmouseover = function (){  // 鼠标箭头在元素里面才行，不然拖动速度太快容易把鼠标划出去，导致不用单机元素就跟着鼠标走。烦的一批。
        odrag.onmousedown = function (ev) {
            var oevent = ev || event;
            var distanceX = oevent.clientX - odrag.offsetLeft;
            var distanceY = oevent.clientY - odrag.offsetTop;
            // var old_x=oevent.clientX;
            // var old_y=oevent.clientY;
            document.onmousemove = function (ev) {
                var oevent = ev || event;
                var _x, _y;
                _x = oevent.clientX - distanceX;
                _y = oevent.clientY - distanceY;
                // 限制元素在屏幕内
                // if (_x < 0) _x = 0;
                // if (_y < 0) _y = 0;
                // if (_x > document.body.clientWidth - odrag.offsetWidth) _x = document.body.clientWidth  - odrag.offsetWidth;
                // if (_y > document.body.clientHeight  - odrag.offsetHeight) _y = document.body.clientHeight  - odrag.offsetHeight;
                odrag.style.left = _x + 'px';
                odrag.style.top = _y + 'px';
            };
            document.onmouseup = function (ev) {
                // var oevent = ev || event;
                // var _x = oevent.clientX - distanceX;
                // var _y = oevent.clientY - distanceY;

                // var leftindex=(_x/$("body").width()).toFixed(2);
                // var topindex=(_y/$("body").height()).toFixed(2);
                //存储位置区域比列或者具体数据
                document.onmousemove = null;
                document.onmouseup = null;
            };
        }

    };
}